"""
author: yzh
date: 2021/1/20
"""
import requests
import re
from api.getKey import getkey,getkeyList
r_jwxt_url = 'https://jwxt-ecut-edu-cn-18801.webvpn1.ecit.cn/caslogin.jsp'
old_JSESSIONID = [""]
def getexe():
    getkey()
    r_jwxt_login_headers = {
        'User-Agent': 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 4 Build/JOP40D) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19',
        "Pragma": "no-cache",
        "Accept": "application/json, text/plain, */*",
        "Cookie": getkeyList[1] + getkeyList[0]
    }
    r_JSESSIONID = requests.get(r_jwxt_url, headers=r_jwxt_login_headers, allow_redirects=False)
    old_JSESSIONID[0] = 'JSESSIONID='+re.findall(r'JSESSIONID=(.*?);', r_JSESSIONID.headers['set-cookie'])[0]+'; '
    return old_JSESSIONID